package com.qezhhnjy.mall.common.http;

import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
public class BaseResult<T> {

    private int code;

    private String message;

    private T data;

    private BaseResult(int code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public static <T> BaseResult<T> success(T data) {
        return new BaseResult<>(1000, "响应成功", data);
    }

    public static <T> BaseResult<T> success() {
        return success(null);
    }

    public static <T> BaseResult<T> error(int code, String message) {
        return new BaseResult<>(code, message, null);
    }

}
